package modele;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.HashMap;

public class DeSerializerPersonne {
	
	private final static DeSerializerPersonne DESER=new DeSerializerPersonne();
	
	public ArrayList<String> read_liste = new ArrayList<String>();
	private HashMap<Integer, String> cache = new HashMap<Integer, String>();
	
	private int j=0;
	private int i=0;
	

	private DeSerializerPersonne() {
		
	}
	
	public  ArrayList<String> deser() {
		
		try {
		
			FileInputStream fichier = new FileInputStream("personne.ser");
			
			ObjectInputStream ois = new ObjectInputStream(fichier);
			
			read_liste=(ArrayList<String>) ois.readObject();
			
			
			
			for(i = 0 ; i < read_liste.size(); i++){
				
				String val= read_liste.get(i);
				
			 	cache.put(i, val);
			 	System.out.println("attribut: " + val); 
			 	
			}
			
			
			
			Integer key =0;
			String value = cache.get(key);
			System.out.println("Key: " + key +" value: "+ value); 
			//System.out.println("Global: " + Global.j); 
			System.out.println("i: " + i); 
			
		
			}
		
			catch (java.io.IOException e) {
		
			e.printStackTrace();
		
			}
			
			catch (ClassNotFoundException e) {
		
			e.printStackTrace();
			}
		
		
		
		return read_liste;
		
			}
	
public static  DeSerializerPersonne getDESER(){
		
		return DESER;
		
	}

	}
